<?php

namespace backend\models;

use yii\helpers\ArrayHelper;
/**
 * This is the ActiveQuery class for [[UserGroup]].
 *
 * @see UserGroup
 */
class UserGroupQuery extends \yii\db\ActiveQuery
{
    /*public function active()
    {
        return $this->andWhere('[[status]]=1');
    }*/

    /**
     * @inheritdoc
     * @return UserGroup[]|array
     */
    public function all($db = null)
    {
        return parent::all($db);
    }

    public function getNameById($id){
        $model = UserGroup::find()->where(['id'=>$id])->one();
        return $model?$model['name']:'';
    }
    
    public function getAllByArray(){
        $models = UserGroup::find()->all();
        $models = ArrayHelper::map($models,'id','name');
        return $models?$models:[];
    }
    
    /**
     * @inheritdoc
     * @return UserGroup|array|null
     */
    public function one($db = null)
    {
        return parent::one($db);
    }
}
